package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.CarserviceitemsdDao;
import io.renren.dto.CarserviceitemsdDTO;
import io.renren.entity.CarserviceitemsdEntity;
import io.renren.entity.GiftpackagerulemEntity;
import io.renren.service.CarserviceitemsdService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * ${comments}
 *
 * @author Sen 524227263@qq.com
 * @since 1.0.0 2024-05-30
 */
@Service
public class CarserviceitemsdServiceImpl extends CrudServiceImpl<CarserviceitemsdDao, CarserviceitemsdEntity, CarserviceitemsdDTO> implements CarserviceitemsdService {

    @Override
    public QueryWrapper<CarserviceitemsdEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");

        QueryWrapper<CarserviceitemsdEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<Map<String, Object>> findListByAutoServiceMFK(String fk) {
        List<Map<String, Object>> list = this.baseDao.selectMaps(
                new QueryWrapper<CarserviceitemsdEntity>()
                        .select("(TransactCost+AgencyCost) as Amount,(TransactCost+OriginalAgencyCost) as BusinessAmount,DiscountAmount,ProduceAccountAmount,ProjectM_FK")
                        .eq("AutoServiceM_FK", fk));
        return list;
    }
}